
%complicated average velocity between points. Averages velocity between
%previous distance and forward distance. A bit unnecessary but slightly
%useful.
function [ V ] = velocity( X,Y )
    INTERVAL =1;
    len = length(X);
    V = zeros(len-1,1);
    for j=INTERVAL+1:len-INTERVAL
       dist_back =  Distance(X(j),X(j+INTERVAL), Y(j), Y(j+INTERVAL))/INTERVAL;
       dist_forward = Distance(X(j),X(j-INTERVAL), Y(j), Y(j-INTERVAL))/INTERVAL;
       V(j+INTERVAL)= (dist_back + dist_forward) /2;         
    end
    
end


%calculates distance between 2 2D points.
function [d] = Distance(x1,x2,y1,y2)
    d= sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
end





